package com.koron.device.utils;

import cn.hutool.core.collection.CollUtil;
import com.koron.bean.standard.deviceClasssify.po.Type;
import com.koron.device.bean.template.EquipmentTemplate;
import com.koron.device.bean.template.LocationTemplate;
import com.koron.device.mapper.TypeParamsMapper;
import org.koron.ebs.mybatis.ADOConnection;

import java.util.List;


public class EqtempInitData {

    /**
     * 台账模板数据初始化
     * @param list
     */
    public static void initEquipmentData(List<EquipmentTemplate> list){
        Type type = ADOConnection.runTask(factory -> {
            List<Type> types = factory.getMapper(TypeParamsMapper.class).queryAllType();
            if (CollUtil.isEmpty(types)) {
                Type temp = new Type();
                temp.setCode("003002006001");
                temp.setName("氧化锌避雷器");
                return temp;
            }
            return types.get(0);
        }, Type.class);
        EquipmentTemplate eq1 = new EquipmentTemplate();
        eq1.setLevelPath("1");
        eq1.setName("节点一(模拟数据)");
        eq1.setIsVirtualStr("实体节点");
        eq1.setFloorStr("系统");
        eq1.setTypeName(type.getParentName());
        eq1.setTypeCode(type.getCode());
        list.add(eq1);
        EquipmentTemplate eq2 = new EquipmentTemplate();
        eq2.setLevelPath("1.1");
        eq2.setName("节点一(子节点一)");
        eq2.setIsVirtualStr("实体节点");
        eq2.setFloorStr("设备");
        eq2.setTypeName(type.getParentName());
        eq2.setTypeCode(type.getCode());
        list.add(eq2);
        EquipmentTemplate eq3 = new EquipmentTemplate();
        eq3.setLevelPath("1.2");
        eq3.setName("节点一(子节点二)");
        eq3.setIsVirtualStr("实体节点");
        eq3.setFloorStr("设备");
        eq3.setTypeName(type.getParentName());
        eq3.setTypeCode(type.getCode());
        list.add(eq3);
        return;
    }

    /**
     * 位置模板数据初始化
     * @param list
     */
    public static void initLocationData(List<LocationTemplate> list){
        LocationTemplate lc1 = new LocationTemplate();
        lc1.setParentCode("80a3eca5-4e92-11ec-87be-0242ac110002");
        lc1.setName("位置一");
        lc1.setCode("80a4da96-4e92-12ec-87be-0242ac110302");
        lc1.setYdu("114.223322");
        lc1.setXdu("22.110098");
        lc1.setRange(200);
        lc1.setStatus("启用");
        LocationTemplate lc2 = new LocationTemplate();
        lc2.setParentCode("80a3eca5-4e92-11ec-87be-0242ac110002");
        lc2.setName("位置二");
        lc2.setCode("80a4db96-4e92-22ec-87be-0252ac110302");
        lc2.setYdu("124.223322");
        lc2.setXdu("44.110098");
        lc2.setRange(400);
        lc2.setStatus("启用");
        return;
    }


}
